home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_gimp / BIN / GIMPTOOL < prev   
Text File  |  1999-09-17  |  9KB  |  293 lines

  1. #! /bin/sh
  2.  
  3. prefix=/usr/local/gimp
  4. exec_prefix=${prefix}
  5. exec_prefix_set=no
  6. plug_in_dir=${exec_prefix}/lib/gimp/1.0
  7. data_dir=${prefix}/share/gimp
  8.  
  9. usage()
  10. {
  11.   cat <<EOF
  12. Usage: gimptool [OPTION]...
  13.  
  14. General options:
  15.   --help                  print this message
  16.   --quiet, --silent       don't echo build commands
  17.   --version               print the version of GIMP associated with this script
  18.   -n, --just-print, --dry-run, --recon
  19.                           don't actually run any commands; just print them
  20. Developer options:
  21.   --cflags                print the compiler flags that are necessary to
  22.                           compile a plug-in
  23.   --libs                  print the linker flags that are necessary to link a
  24.                           plug-in
  25.   --prefix=PREFIX         use PREFIX instead of the installation prefix that
  26.                           GIMP was built when computing the output for --cflags
  27.                           and --libs
  28.   --exec-prefix=PREFIX    use PREFIX instead of the installation exec prefix
  29.                           that GIMP was built when computing the output for
  30.                           --cflags and --libs
  31.  
  32. The --cflags and --libs options can be appended with -noui to get appropriate
  33. settings for plug-ins which do not use GTK+.
  34.  
  35. User options:
  36.   --build plug-in.c               build a plug-in from a source file
  37.   --install plug-in.c             same as --build, but installs the built
  38.                                   plug-in as well
  39.   --install-bin plug-in           install a compiled plug-in
  40.   --install-script script.scm     install a script-fu script
  41.  
  42. The --install options can be prefixed with --install-admin instead to install
  43. a plug-in or script in the site directory instead of a user directory.
  44.  
  45. For plug-ins which do not use GTK+, the --build and --install options can be
  46. appended with -noui for appropriate settings. For plug-ins that use GTK+ but
  47. not libgumpui, append -nogimpui.
  48.  
  49. All binary build and install options can be appended with -strip to discard
  50. debugging information.
  51. EOF
  52.  
  53.   exit $1
  54. }
  55.  
  56. noarg="\
  57. Error: Need a plug-in source file to build"
  58.  
  59. notfound="\
  60. Error: Couldn't find source file to build"
  61.  
  62. quiet=no
  63. donothing=no
  64.  
  65. if test $# -eq 0; then
  66.   usage 1
  67. fi
  68.  
  69. if test x${GTK_CONFIG+set} != xset ; then
  70.   gtk_cflags='-I/usr/local/gtk/include -I/usr/X11R6/include -I/usr/local/glib/lib/glib/include -I/usr/local/glib/include'
  71.   gtk_libs='-L/usr/local/gtk/lib -L/usr/X11R6/lib -lgtk -lgdk -L/usr/local/glib/lib -rdynamic -lgmodule -lglib -ldl -lintl -lXext -lX11 -lm'
  72. else
  73.   gtk_cflags=`$GTK_CONFIG --cflags`
  74.   gtk_libs=`$GTK_CONFIG --libs`
  75. fi
  76.  
  77. if test x${INSTALL+set} != xset ; then
  78.   INSTALL='/usr/bin/ginstall -c'
  79. fi
  80.  
  81. if test x${CC+set} != xset ; then
  82.   cc='gcc'
  83. else
  84.   cc="$CC"
  85. fi
  86.  
  87. if test x${CFLAGS+set} != xset ; then
  88.   cflags='-g -O2 -Wall'
  89. else
  90.   cflags="$CFLAGS"
  91. fi
  92.  
  93. if test x${LDFLAGS+set} != xset ; then
  94.   ldflags='-L/usr/local/libtiff/lib -L/usr/local/zlib/lib -L/usr/local/libpng/lib -L/usr/local/libmpeg/lib -L/usr/local/libjpeg/lib -L/usr/local/aalib/lib'
  95. else
  96.   ldflags="$LDFLAGS"
  97. fi
  98.  
  99. if test x${LIBS+set} != xset ; then
  100.   libs=""
  101. else
  102.   libs="$LIBS"
  103. fi
  104.  
  105. while test $# -gt 0; do
  106.   case "$1" in
  107.   -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  108.   *) optarg= ;;
  109.   esac
  110.  
  111.   case $1 in
  112.     --version)
  113.       echo 1.0.4
  114.       exit 0
  115.       ;;
  116.     --help)
  117.       usage 0
  118.       ;;
  119.     --quiet | --silent)
  120.       quiet=yes
  121.       ;;
  122.     -n | --just-print | --dry-run | --recon)
  123.       donothing=yes
  124.       ;;
  125.     --prefix=*)
  126.       prefix=$optarg
  127.       if test $exec_prefix_set = no ; then
  128.         exec_prefix=$optarg
  129.       fi
  130.       ;;
  131.     --prefix)
  132.       echo $prefix
  133.       ;;
  134.     --exec-prefix=*)
  135.       exec_prefix=$optarg
  136.       exec_prefix_set=yes
  137.       ;;
  138.     --exec-prefix)
  139.       echo $exec_prefix
  140.       ;;
  141.     --cflags | --cflags-noui | --cflags-nogimpui)
  142.       case $1 in
  143.         --cflags | --cflags-nogimpui)
  144.           my_gtk_cflags=$gtk_cflags ;;
  145.         --cflags-noui)
  146.           my_gtk_cflags=`echo $gtk_cflags | sed 's/^.*\(-I[^ ]*glib[^ ]*  *-I[^ ]*\).*$/\1/'` ;;
  147.       esac
  148.       if test ${prefix}/include != /usr/include ; then
  149.         includes=-I${prefix}/include
  150.         for i in $my_gtk_cflags ; do
  151.           if test $i = -I${prefix}/include ; then
  152.              includes=""
  153.           fi
  154.         done
  155.       fi
  156.       echo $includes $my_gtk_cflags
  157.       ;;
  158.     --libs | --libs-nogimpui)
  159.       my_gtk_libs=
  160.       libdirs=-L${exec_prefix}/lib
  161.       for i in $gtk_libs ; do
  162.         if test $i != -L${exec_prefix}/lib ; then
  163.           if test -z "$my_gtk_libs" ; then
  164.             my_gtk_libs="$i"
  165.           else
  166.             my_gtk_libs="$my_gtk_libs $i"
  167.           fi
  168.         fi
  169.       done
  170.       case $1 in
  171.         --libs)
  172.           echo $libdirs -lgimpui -lgimp $my_gtk_libs ;;
  173.         --libs-nogimpui)
  174.           echo $libdirs -lgimp $my_gtk_libs ;;
  175.       esac
  176.       ;;
  177.     --libs-noui)
  178.       glib_ldflags=`echo $gtk_libs | sed -e 's/^.*-lgdk[^ ]* *\(-L[^ ]*\).*$/\1/' -e 's/^.* -lgdk[^ ]* .*$//'`
  179.       if test -z "$glib_ldflags" ; then
  180.         glib_ldflags=`echo $gtk_libs | sed 's/^ *\(-L[^ ]*\) .*$/\1/'`
  181.       fi 
  182.       glib_libs="$glib_ldflags `echo $gtk_libs | sed 's/^.*\(-lglib[^ ]*\).*$/\1/'`"
  183.       my_glib_libs=
  184.       libdirs=-L${exec_prefix}/lib
  185.       for i in $glib_libs ; do
  186.         if test $i != -L${exec_prefix}/lib ; then
  187.           if test -z "$my_glib_libs" ; then
  188.             my_glib_libs="$i"
  189.           else
  190.             my_glib_libs="$my_glib_libs $i"
  191.           fi
  192.         fi
  193.       done
  194.       echo -L${exec_prefix}/lib -lgimp $my_glib_libs
  195.       ;;
  196.     --install-bin | --install-admin-bin \
  197.     | --install-bin-strip | --install-admin-bin-strip \
  198.     | --install-script | --install-admin-script)
  199.       case $1 in
  200.         --install-bin)
  201.           install_cmd="${INSTALL}"
  202.           install_dir="$HOME/.gimp/plug-ins"
  203.           ;;
  204.         --install-bin-strip)
  205.           install_cmd="${INSTALL} -s"
  206.           install_dir="$HOME/.gimp/plug-ins"
  207.           ;;
  208.         --install-admin-bin)
  209.           install_cmd="${INSTALL}"
  210.           install_dir="$plug_in_dir/plug-ins"
  211.           ;;
  212.         --install-admin-bin-strip)
  213.           install_cmd="${INSTALL} -s"
  214.           install_dir="$plug_in_dir/plug-ins"
  215.           ;;
  216.         --install-script)
  217.           install_cmd="${INSTALL} -m 644"
  218.           install_dir="$HOME/.gimp/scripts"
  219.           ;;
  220.         --install-admin-script)
  221.           install_cmd="${INSTALL} -m 644"
  222.           install_dir="$data_dir/scripts"
  223.           ;;
  224.       esac
  225.       shift
  226.       if test "x$1" != "x"; then
  227.         if test -r "$1"; then
  228.           cmd="$install_cmd $1 $install_dir/$1"
  229.           test $quiet = "yes" || echo $cmd
  230.           test $donothing = "yes" || exec $cmd
  231.         else
  232.           echo "${notfound}" 1>&2
  233.           exit 1
  234.         fi  
  235.       else
  236.         echo "${noarg}" 1>&2
  237.         exit 1
  238.       fi
  239.       ;;
  240.     --build | --install | --install-admin | --build-strip | --install-strip \
  241.     | --install-admin-strip | --build-nogimpui | --install-nogimpui \
  242.     | --install-admin-nogimpui | --build-nogimpui-strip \
  243.     | --install-nogimpui-strip | --install-admin-nogimpui-strip \
  244.     | --build-noui | --install-noui | --install-admin-noui \
  245.     | --build-noui-strip | --install-noui-strip | --install-admin-noui-strip)
  246.       opt=`echo $1 | sed 's/-strip$//'`
  247.       if test "x$opt" != "x$1" ; then
  248.         cflags=`echo $cflags | sed -e 's/-g //g' -e 's/ -g//g'`
  249.       fi
  250.       case $opt in
  251.         --build | --build-noui | --build-nogimpui)
  252.           install_dir=. ;;
  253.         --install | --install-noui | --install-nogimpui)
  254.           install_dir="$HOME/.gimp/plug-ins" ;;
  255.         --install-admin | --install-admin-noui | --install-admin-nogimpui)
  256.           install_dir="$plug_in_dir/plug-ins" ;;
  257.       esac
  258.       noui=`echo $opt | sed 's/^.*\(noui\)$/\1/'`
  259.       nogimpui=`echo $opt | sed 's/^.*\(nogimpui\)$/\1/'`
  260.       if test "$noui" = "noui" ; then
  261.         gimp_cflags=`$0 --cflags-noui`
  262.         gimp_libs=`$0 --libs-noui`
  263.       elif test "$nogimpui" = "nogimpui" ; then
  264.         gimp_cflags=`$0 --cflags-nogimpui`
  265.         gimp_libs=`$0 --libs-nogimpui`
  266.       else
  267.         gimp_cflags=`$0 --cflags`
  268.         gimp_libs=`$0 --libs`
  269.       fi
  270.       shift
  271.       if test "x$1" != "x"; then
  272.         if test -r "$1"; then
  273.           dest=`echo $1 | sed -e 's#.*/\([^/].*\)$#\1#' -e 's/\.[^.]*$//'`
  274.           cmd="$cc $cflags $gimp_cflags -o $install_dir/$dest $1 $ldflags $gimp_libs $libs"
  275.           test $quiet = "yes" || echo $cmd
  276.           test $donothing = "yes" || exec $cmd
  277.         else
  278.           echo "${notfound}" 1>&2
  279.           exit 1
  280.         fi  
  281.       else
  282.         echo "${noarg}" 1>&2
  283.         exit 1
  284.       fi
  285.       ;;
  286.     *)
  287.       usage 1
  288.       ;;
  289.   esac
  290.   shift
  291. done
  292.  
  293.